package me.raih.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author Raih
 * @Time 2020/12/29 13:31
 */
public class SalesHandlerInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        Object sales_flag = request.getSession().getAttribute("SALES_LOGIN_SESSION_FLAG");

        if(sales_flag == null){
            response.sendRedirect("/admin/login");

            System.out.println("哎呦小哥，你走错路了");

            return false;
        }else {
            return true;
        }
    }
}
